import axios from 'axios';

export const request = axios.create({
    baseURL: 'http://192.168.31.185:5000',
    withCredentials: true,
    headers: {
        'Content-Type': 'application/json'
    },
    validateStatus: function (status) {
        return status >= 200 && status < 500;
    }
});

// 添加响应拦截器
request.interceptors.response.use(
    (response) => response,
    (error) => {
        console.error('API Error:', error);
        if (error.response) {
            console.error('Server Error:', error.response.data);
        }
        return Promise.reject(error);
    }
);
